/****************************************************************************
**  Tite Interactive Text Engine (TiTE)
**  Copyright (C) 2010  Eisoft Group
**
**  This file is part of TiTE.
**
**  TiTE is free software: you can redistribute it and/or modify
**  it under the terms of the GNU General Public License as published by
**  the Free Software Foundation, either version 3 of the License, or
**  (at your option) any later version.
**
**  TiTE is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**  GNU General Public License for more details.
**
**  You should have received a copy of the GNU General Public License
**  along with TiTE.  If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

/*!
 * \file make_shared_COM.hpp
 *
 * \date 01/10/2011
 */

#ifndef TITE_CORE_MAKE_SHARED_COM_HPP
#define TITE_CORE_MAKE_SHARED_COM_HPP

/*!
 * \namespace tite
 *
 * \brief The TiTE namespace.
 */
namespace tite
{
    /*!
     * \namespace core
     *
     * \brief The TiTE core namespace.
     */
    namespace core
    {
        /*!
         * \brief Constructs a shared_ptr from a COM object, allowing COM objects
         *        to be treated as normal shared_ptr smart pointers.
         *
         * \param _pComObj  Allocated COM object.
         *
         * \return A shared_ptr-owned COM object.
         */
        inline stdext::shared_ptr<IUnknown> make_shared_COM(IUnknown * _pComObj)
        {
            _pComObj->AddRef();
            stdext::shared_ptr<IUnknown> ptr(_pComObj, stdext::mem_fn(&IUnknown::Release));
            return ptr;
        }
    }// End of core namespace
}// End of tite namespace

#endif /* TITE_CORE_MAKE_SHARED_COM_HPP */